(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^2).


The TRS R consists of the following rules:

U11(tt, M, N) → U12(tt, activate(M), activate(N))
U12(tt, M, N) → s(plus(activate(N), activate(M)))
U21(tt, M, N) → U22(tt, activate(M), activate(N))
U22(tt, M, N) → plus(x(activate(N), activate(M)), activate(N))
plus(N, 0) → N
plus(N, s(M)) → U11(tt, M, N)
x(N, 0) → 0
x(N, s(M)) → U21(tt, M, N)
activate(X) → X

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^2).


The TRS R consists of the following rules:

U11(tt, M, N) → U12(tt, activate(M), activate(N)) [1]
U12(tt, M, N) → s(plus(activate(N), activate(M))) [1]
U21(tt, M, N) → U22(tt, activate(M), activate(N)) [1]
U22(tt, M, N) → plus(x(activate(N), activate(M)), activate(N)) [1]
plus(N, 0) → N [1]
plus(N, s(M)) → U11(tt, M, N) [1]
x(N, 0) → 0 [1]
x(N, s(M)) → U21(tt, M, N) [1]
activate(X) → X [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

U11(tt, M, N) → U12(tt, activate(M), activate(N)) [1]
U12(tt, M, N) → s(plus(activate(N), activate(M))) [1]
U21(tt, M, N) → U22(tt, activate(M), activate(N)) [1]
U22(tt, M, N) → plus(x(activate(N), activate(M)), activate(N)) [1]
plus(N, 0) → N [1]
plus(N, s(M)) → U11(tt, M, N) [1]
x(N, 0) → 0 [1]
x(N, s(M)) → U21(tt, M, N) [1]
activate(X) → X [1]

The TRS has the following type information:
U11 :: tt → s:0 → s:0 → s:0
tt :: tt
U12 :: tt → s:0 → s:0 → s:0
activate :: s:0 → s:0
s :: s:0 → s:0
plus :: s:0 → s:0 → s:0
U21 :: tt → s:0 → s:0 → s:0
U22 :: tt → s:0 → s:0 → s:0
x :: s:0 → s:0 → s:0
0 :: s:0

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:
none

And the following fresh constants: none

(6) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

U11(tt, M, N) → U12(tt, activate(M), activate(N)) [1]
U12(tt, M, N) → s(plus(activate(N), activate(M))) [1]
U21(tt, M, N) → U22(tt, activate(M), activate(N)) [1]
U22(tt, M, N) → plus(x(activate(N), activate(M)), activate(N)) [1]
plus(N, 0) → N [1]
plus(N, s(M)) → U11(tt, M, N) [1]
x(N, 0) → 0 [1]
x(N, s(M)) → U21(tt, M, N) [1]
activate(X) → X [1]

The TRS has the following type information:
U11 :: tt → s:0 → s:0 → s:0
tt :: tt
U12 :: tt → s:0 → s:0 → s:0
activate :: s:0 → s:0
s :: s:0 → s:0
plus :: s:0 → s:0 → s:0
U21 :: tt → s:0 → s:0 → s:0
U22 :: tt → s:0 → s:0 → s:0
x :: s:0 → s:0 → s:0
0 :: s:0

Rewrite Strategy: INNERMOST

(7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

tt => 0
0 => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

U11(z, z', z'') -{ 1 }→ U12(0, activate(M), activate(N)) :|: z' = M, z = 0, z'' = N, M >= 0, N >= 0
U12(z, z', z'') -{ 1 }→ 1 + plus(activate(N), activate(M)) :|: z' = M, z = 0, z'' = N, M >= 0, N >= 0
U21(z, z', z'') -{ 1 }→ U22(0, activate(M), activate(N)) :|: z' = M, z = 0, z'' = N, M >= 0, N >= 0
U22(z, z', z'') -{ 1 }→ plus(x(activate(N), activate(M)), activate(N)) :|: z' = M, z = 0, z'' = N, M >= 0, N >= 0
activate(z) -{ 1 }→ X :|: X >= 0, z = X
plus(z, z') -{ 1 }→ N :|: z = N, z' = 0, N >= 0
plus(z, z') -{ 1 }→ U11(0, M, N) :|: z' = 1 + M, z = N, M >= 0, N >= 0
x(z, z') -{ 1 }→ U21(0, M, N) :|: z' = 1 + M, z = N, M >= 0, N >= 0
x(z, z') -{ 1 }→ 0 :|: z = N, z' = 0, N >= 0

Only complete derivations are relevant for the runtime complexity.

(9) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V1, V2),0,[fun(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]).
eq(start(V, V1, V2),0,[fun1(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]).
eq(start(V, V1, V2),0,[fun2(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]).
eq(start(V, V1, V2),0,[fun3(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]).
eq(start(V, V1, V2),0,[plus(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1, V2),0,[x(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1, V2),0,[activate(V, Out)],[V >= 0]).
eq(fun(V, V1, V2, Out),1,[activate(M1, Ret1),activate(N1, Ret2),fun1(0, Ret1, Ret2, Ret)],[Out = Ret,V1 = M1,V = 0,V2 = N1,M1 >= 0,N1 >= 0]).
eq(fun1(V, V1, V2, Out),1,[activate(N2, Ret10),activate(M2, Ret11),plus(Ret10, Ret11, Ret12)],[Out = 1 + Ret12,V1 = M2,V = 0,V2 = N2,M2 >= 0,N2 >= 0]).
eq(fun2(V, V1, V2, Out),1,[activate(M3, Ret13),activate(N3, Ret21),fun3(0, Ret13, Ret21, Ret3)],[Out = Ret3,V1 = M3,V = 0,V2 = N3,M3 >= 0,N3 >= 0]).
eq(fun3(V, V1, V2, Out),1,[activate(N4, Ret00),activate(M4, Ret01),x(Ret00, Ret01, Ret0),activate(N4, Ret14),plus(Ret0, Ret14, Ret4)],[Out = Ret4,V1 = M4,V = 0,V2 = N4,M4 >= 0,N4 >= 0]).
eq(plus(V, V1, Out),1,[],[Out = N5,V = N5,V1 = 0,N5 >= 0]).
eq(plus(V, V1, Out),1,[fun(0, M5, N6, Ret5)],[Out = Ret5,V1 = 1 + M5,V = N6,M5 >= 0,N6 >= 0]).
eq(x(V, V1, Out),1,[],[Out = 0,V = N7,V1 = 0,N7 >= 0]).
eq(x(V, V1, Out),1,[fun2(0, M6, N8, Ret6)],[Out = Ret6,V1 = 1 + M6,V = N8,M6 >= 0,N8 >= 0]).
eq(activate(V, Out),1,[],[Out = X1,X1 >= 0,V = X1]).
input_output_vars(fun(V,V1,V2,Out),[V,V1,V2],[Out]).
input_output_vars(fun1(V,V1,V2,Out),[V,V1,V2],[Out]).
input_output_vars(fun2(V,V1,V2,Out),[V,V1,V2],[Out]).
input_output_vars(fun3(V,V1,V2,Out),[V,V1,V2],[Out]).
input_output_vars(plus(V,V1,Out),[V,V1],[Out]).
input_output_vars(x(V,V1,Out),[V,V1],[Out]).
input_output_vars(activate(V,Out),[V],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. non_recursive : [activate/2]
1. recursive : [fun/4,fun1/4,plus/3]
2. recursive [non_tail] : [fun2/4,fun3/4,x/3]
3. non_recursive : [start/3]

#### Obtained direct recursion through partial evaluation
0. SCC is completely evaluated into other SCCs
1. SCC is partially evaluated into plus/3
2. SCC is partially evaluated into x/3
3. SCC is partially evaluated into start/3

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations plus/3
* CE 12 is refined into CE [13]
* CE 11 is refined into CE [14]


### Cost equations --> "Loop" of plus/3
* CEs [14] --> Loop 6
* CEs [13] --> Loop 7

### Ranking functions of CR plus(V,V1,Out)
* RF of phase [6]: [V1]

#### Partial ranking functions of CR plus(V,V1,Out)
* Partial RF of phase [6]:
- RF of loop [6:1]:
V1


### Specialization of cost equations x/3
* CE 10 is refined into CE [15]
* CE 9 is refined into CE [16,17]


### Cost equations --> "Loop" of x/3
* CEs [17] --> Loop 8
* CEs [16] --> Loop 9
* CEs [15] --> Loop 10

### Ranking functions of CR x(V,V1,Out)
* RF of phase [8]: [V1]
* RF of phase [9]: [V1]

#### Partial ranking functions of CR x(V,V1,Out)
* Partial RF of phase [8]:
- RF of loop [8:1]:
V1
* Partial RF of phase [9]:
- RF of loop [9:1]:
V1


### Specialization of cost equations start/3
* CE 2 is refined into CE [18,19,20,21]
* CE 3 is refined into CE [22,23,24,25]
* CE 4 is refined into CE [26,27]
* CE 5 is refined into CE [28,29]
* CE 6 is refined into CE [30,31]
* CE 7 is refined into CE [32,33,34]
* CE 8 is refined into CE [35]


### Cost equations --> "Loop" of start/3
* CEs [18,21,22,25,27,29,32] --> Loop 11
* CEs [19,20,23,24,26,28,30,31,33,34,35] --> Loop 12

### Ranking functions of CR start(V,V1,V2)

#### Partial ranking functions of CR start(V,V1,V2)


Computing Bounds
=====================================

#### Cost of chains of plus(V,V1,Out):
* Chain [[6],7]: 7*it(6)+1
Such that:it(6) =< V1

with precondition: [V+V1=Out,V>=0,V1>=1]

* Chain [7]: 1
with precondition: [V1=0,V=Out,V>=0]


#### Cost of chains of x(V,V1,Out):
* Chain [[9],10]: 9*it(9)+1
Such that:it(9) =< V1

with precondition: [V=0,Out=0,V1>=1]

* Chain [[8],10]: 9*it(8)+7*s(3)+1
Such that:aux(1) =< V
it(8) =< V1
s(3) =< it(8)*aux(1)

with precondition: [V>=1,V1>=1,Out+1>=V+V1]

* Chain [10]: 1
with precondition: [V1=0,Out=0,V>=0]


#### Cost of chains of start(V,V1,V2):
* Chain [12]: 14*s(4)+16*s(6)+7*s(9)+9
Such that:s(7) =< V
aux(2) =< V1
aux(3) =< V2
s(6) =< aux(2)
s(4) =< aux(3)
s(9) =< s(6)*s(7)

with precondition: [V>=0]

* Chain [11]: 59*s(10)+14*s(13)+14*s(14)+9
Such that:aux(6) =< V1
aux(7) =< V2
s(10) =< aux(6)
s(14) =< aux(7)
s(13) =< s(10)*aux(7)

with precondition: [V=0,V1>=1]


Closed-form bounds of start(V,V1,V2):
-------------------------------------
* Chain [12] with precondition: [V>=0]
- Upper bound: 7*V*nat(V1)+9+nat(V1)*16+nat(V2)*14
- Complexity: n^2
* Chain [11] with precondition: [V=0,V1>=1]
- Upper bound: 59*V1+9+nat(V2)*14+nat(V2)*14*V1
- Complexity: n^2

### Maximum cost of start(V,V1,V2): nat(V1)*16+9+nat(V2)*14+max([7*V*nat(V1),nat(V2)*14*nat(V1)+nat(V1)*43])
Asymptotic class: n^2
* Total analysis performed in 226 ms.

(10) BOUNDS(1, n^2)